from app import app
from app.models import db
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager, Shell, Server
from generate_code import generate_code

manager = Manager(app)
migrate = Migrate(app, db)


def make_shell_context():
	return dict(app=app, db=db)


manager.add_command('shell', Shell(make_context=make_shell_context))
manager.add_command('db', MigrateCommand)

@manager.command
def generate():
	from app.models.user import Student
	generate_code(Student)


if __name__ == "__main__":
	manager.add_command("runserver", Server(
		host="0.0.0.0", port=5000, use_debugger=True, use_reloader=True))
	manager.run()
